import { createStore } from "vuex";
export default createStore({
  state: {
    userName: "",
  },
  mutations: {
    // 同步操作
    changeUserName(state, payload) {
      state.userName = payload;
    },
  },
  actions: {
    // 异步操作
    updateUserName(context, payload) {
      context.commit("changeUserName", payload);
    },
  },
  getters: {
    getUserName(state) {
      return state?.userName ? `${state.userName}~` : "暂时还没有设置用户名哦~";
    },
  },
  modules: {},
});
